//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for WorkSpaces
public struct WorkSpacesErrorType: AWSErrorType {
    enum Code: String {
        case accessDeniedException = "AccessDeniedException"
        case invalidParameterValuesException = "InvalidParameterValuesException"
        case invalidResourceStateException = "InvalidResourceStateException"
        case operationInProgressException = "OperationInProgressException"
        case operationNotSupportedException = "OperationNotSupportedException"
        case resourceAlreadyExistsException = "ResourceAlreadyExistsException"
        case resourceAssociatedException = "ResourceAssociatedException"
        case resourceCreationFailedException = "ResourceCreationFailedException"
        case resourceLimitExceededException = "ResourceLimitExceededException"
        case resourceNotFoundException = "ResourceNotFoundException"
        case resourceUnavailableException = "ResourceUnavailableException"
        case unsupportedNetworkConfigurationException = "UnsupportedNetworkConfigurationException"
        case unsupportedWorkspaceConfigurationException = "UnsupportedWorkspaceConfigurationException"
        case workspacesDefaultRoleNotFoundException = "WorkspacesDefaultRoleNotFoundException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize WorkSpaces
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// The user is not authorized to access a resource.
    public static var accessDeniedException: Self { .init(.accessDeniedException) }
    /// One or more parameter values are not valid.
    public static var invalidParameterValuesException: Self { .init(.invalidParameterValuesException) }
    /// The state of the resource is not valid for this operation.
    public static var invalidResourceStateException: Self { .init(.invalidResourceStateException) }
    /// The properties of this WorkSpace are currently being modified. Try again in a moment.
    public static var operationInProgressException: Self { .init(.operationInProgressException) }
    /// This operation is not supported.
    public static var operationNotSupportedException: Self { .init(.operationNotSupportedException) }
    /// The specified resource already exists.
    public static var resourceAlreadyExistsException: Self { .init(.resourceAlreadyExistsException) }
    /// The resource is associated with a directory.
    public static var resourceAssociatedException: Self { .init(.resourceAssociatedException) }
    /// The resource could not be created.
    public static var resourceCreationFailedException: Self { .init(.resourceCreationFailedException) }
    /// Your resource limits have been exceeded.
    public static var resourceLimitExceededException: Self { .init(.resourceLimitExceededException) }
    /// The resource could not be found.
    public static var resourceNotFoundException: Self { .init(.resourceNotFoundException) }
    /// The specified resource is not available.
    public static var resourceUnavailableException: Self { .init(.resourceUnavailableException) }
    /// The configuration of this network is not supported for this operation, or your network configuration conflicts with the Amazon WorkSpaces management network IP range. For more information, see  Configure a VPC for Amazon WorkSpaces.
    public static var unsupportedNetworkConfigurationException: Self { .init(.unsupportedNetworkConfigurationException) }
    /// The configuration of this WorkSpace is not supported for this operation. For more information, see Required Configuration and Service Components for WorkSpaces .
    public static var unsupportedWorkspaceConfigurationException: Self { .init(.unsupportedWorkspaceConfigurationException) }
    /// The workspaces_DefaultRole role could not be found. If this is the first time you are registering a directory, you will need to create the workspaces_DefaultRole role before you can register a directory. For more information, see Creating the workspaces_DefaultRole Role.
    public static var workspacesDefaultRoleNotFoundException: Self { .init(.workspacesDefaultRoleNotFoundException) }
}

extension WorkSpacesErrorType: Equatable {
    public static func == (lhs: WorkSpacesErrorType, rhs: WorkSpacesErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension WorkSpacesErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
